local util = require("tests.test_util")

describe("treesitter elixir", function()
  it("parses all symbols correctly", function()
    util.test_file_symbols("treesitter", "./tests/treesitter/elixir_test.exs", {
      {
        kind = "Module",
        name = "Example.Module",
        level = 0,
        lnum = 1,
        col = 0,
        end_lnum = 22,
        end_col = 3,
        children = {
          {
            kind = "Field",
            name = ":value",
            level = 1,
            lnum = 5,
            col = 2,
            end_lnum = 5,
            end_col = 26,
          },
          {
            kind = "Function",
            name = "public_function",
            level = 1,
            lnum = 7,
            col = 2,
            end_lnum = 8,
            end_col = 5,
          },
          {
            kind = "Function",
            name = "private_function",
            level = 1,
            scope = "private",
            lnum = 10,
            col = 2,
            end_lnum = 11,
            end_col = 5,
          },
          {
            kind = "Function",
            name = "public_guard",
            level = 1,
            lnum = 13,
            col = 2,
            end_lnum = 13,
            end_col = 42,
          },
          {
            kind = "Function",
            name = "private_guard",
            level = 1,
            lnum = 15,
            col = 2,
            end_lnum = 15,
            end_col = 43,
          },
          {
            kind = "Function",
            name = "public_macro",
            level = 1,
            lnum = 17,
            col = 2,
            end_lnum = 18,
            end_col = 5,
          },
          {
            kind = "Function",
            name = "private_macro",
            level = 1,
            lnum = 20,
            col = 2,
            end_lnum = 21,
            end_col = 5,
          },
        },
      },
      {
        kind = "Interface",
        name = "Example.Behaviour",
        level = 0,
        lnum = 24,
        col = 0,
        end_lnum = 26,
        end_col = 3,
        children = {
          {
            kind = "Function",
            name = "example_function",
            level = 1,
            lnum = 25,
            col = 2,
            end_lnum = 25,
            end_col = 46,
          },
        },
      },
      {
        kind = "Struct",
        name = "Example.Struct",
        level = 0,
        lnum = 28,
        col = 0,
        end_lnum = 31,
        end_col = 3,
        children = {
          {
            kind = "Constant",
            name = "@constant",
            level = 1,
            lnum = 29,
            col = 2,
            end_lnum = 29,
            end_col = 13,
          },
        },
      },
      {
        kind = "Interface",
        name = "Example.Protocol",
        level = 0,
        lnum = 33,
        col = 0,
        end_lnum = 40,
        end_col = 3,
        children = {
          {
            kind = "TypeParameter",
            name = "public_function_head",
            level = 1,
            lnum = 38,
            col = 2,
            end_lnum = 38,
            end_col = 50,
          },
          {
            kind = "Function",
            name = "public_function_head",
            level = 1,
            lnum = 39,
            col = 2,
            end_lnum = 39,
            end_col = 39,
          },
        },
      },
      {
        kind = "Class",
        name = "Map > Example.Protocol",
        level = 0,
        lnum = 42,
        col = 0,
        end_lnum = 47,
        end_col = 3,
        children = {
          {
            kind = "TypeParameter",
            name = "public_function_head",
            level = 1,
            lnum = 43,
            col = 2,
            end_lnum = 43,
            end_col = 56,
          },
          {
            kind = "Function",
            name = "public_function_head",
            level = 1,
            lnum = 44,
            col = 2,
            end_lnum = 46,
            end_col = 5,
          },
        },
      },
      {
        kind = "Module",
        name = "StringTest",
        level = 0,
        lnum = 50,
        col = 0,
        end_lnum = 66,
        end_col = 3,
        children = {
          {
            kind = "Function",
            name = "describe String.capitalize/1",
            level = 1,
            lnum = 53,
            col = 2,
            end_lnum = 65,
            end_col = 5,
            children = {
              {
                kind = "Function",
                name = "setup",
                level = 2,
                lnum = 54,
                col = 4,
                end_lnum = 56,
                end_col = 7,
              },
              {
                kind = "Function",
                name = "test first grapheme is in uppercase",
                level = 2,
                lnum = 58,
                col = 4,
                end_lnum = 60,
                end_col = 7,
              },
              {
                kind = "Function",
                name = "test converts remaining graphemes to lowercase",
                level = 2,
                lnum = 62,
                col = 4,
                end_lnum = 64,
                end_col = 7,
              },
            },
          },
        },
      },
      {
        kind = "Function",
        name = "parameterless_function",
        level = 0,
        lnum = 68,
        col = 0,
        end_lnum = 69,
        end_col = 3,
      },
    })
  end)
end)
